package com.chinasoft.dish.controller;

import com.chinasoft.dish.domain.Dish;
import com.chinasoft.dish.service.DishService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("dish")
public class DishController {

    @Resource
    private DishService dishService;

    /**
     * 查询所有菜品
     * @return
     */
    @GetMapping("findAll")
    public List<Dish> findAll(@RequestParam Map<String,Object> map){
        return dishService.findAll(map);
    }

    /**
     * 根据id查询菜品
     * @param bid
     * @return
     */
    @GetMapping("findOne")
    public List<Dish> findOne(@RequestParam String bid){
        return dishService.findOne(bid);
    }

    /**
     * 添加菜品
     * @param dish
     */
    @PostMapping("addDish")
    public void addDish(Dish dish){
        dishService.addDish(dish);
    }

    /**
     * 根据商家id和菜品名删除菜品
     * @param map
     */
    @PostMapping("delDish")
    public void delDish(@RequestParam Map<String,Object> map){
        dishService.delDish(map);
    }

    /**
     * 修改菜品
     * @param dish
     */
    @PostMapping("updateDish")
    public void updateDish(Dish dish){
        dishService.updateDish(dish);
    }

}
